﻿#region Librerias
using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
#endregion

/// <summary>
/// Class PLegal, dependiente de la clase Person, define una persona juridica
/// </summary>

#region Class

public class clsLogTrans : DAC
{
    #region Variables

    private int idLogTrans, idUser, idProgram, idRegistrationID, flgOperation;
    private DateTime dtTransDate;
    private String sTabladbUniversal;
    private const String tabla = "dbo.tblLogTrans";

    #endregion

    #region Builder

    /// <summary>
    /// Constructor
    /// </summary>
    public clsLogTrans() { }

    #endregion

    #region Methods

    #region Consultations

    public DataSet SeeAllTheRecords()
    {
        String query = "SELECT row_number() over(order by " + tabla + ".idLogTrans) As NUMBER, ";
        query += tabla + ".idLogTrans As ID, " + tabla + ".idUser As USER, ";
        query += tabla + ".idProgram As PROGRAM, " + tabla + ".idRegistrationID As REGISTRATIONID, " + tabla + ".flgOperation As OPERATION ";
        query += " FROM " + tabla;
        return this.ExecuteQuery(query);
    }
    
    public DataSet ConsultID(String id)
    {
        String query = "SELECT row_number() over(order by " + tabla + ".idLogTrans) As NUMBER, ";
        query += tabla + ".idLogTrans As ID, " + tabla + ".idUser As USER, ";
        query += tabla + ".idProgram As PROGRAM, " + tabla + ".idRegistrationID As REGISTRATIONID, " + tabla + ".flgOperation As OPERATION ";
        query += "FROM " + tabla;
        query += " WHERE " + tabla + ".idLogTrans =" + id;
        return this.ExecuteQuery(query);
    }

    #endregion

    public int Insert()
    {
        String query = "INSERT INTO " + tabla;
        query += "(idUser, idProgram, idRegistrationID, flgOperation, dtTransDate, sTabladbUniversal) ";
        query += "VALUES ('{0}','{1}','{2}','{3}','{4}','{5}')";

        String sql = String.Format(query, this.IdUser, this.IdProgram, this.IdRegistrationID, this.FlgOperation, this.DtTransDate, this.STabladbUniversal);
        return this.ExecuteDML(sql, "no");
    }

    public int Update()
    {
        String query = "UPDATE " + tabla + " SET ";
        query += tabla + ".idUser=" + this.IdUser + ", " + tabla + ".idProgram=" + this.IdProgram + ", ";
        query += tabla + ".idRegistrationID=" + this.IdRegistrationID + ", " + tabla + ".flgOperation=" + this.FlgOperation + ", ";
        query += tabla + ".dtTransDate=" + this.DtTransDate + ", " + tabla + ".sTabladbUniversal='" + this.STabladbUniversal + "' ";
        query += "WHERE ";
        query += tabla + ".idLogTrans=" + this.ID;
        return this.ExecuteDML(query, "no");
    }

    public int Delete()
    {
        String query = "DELETE FROM " + tabla + " WHERE " + tabla + ".idLogTrans={0}";
        String sql = String.Format(query, this.ID);
        return this.ExecuteDML(sql, "no");
    }

    #endregion

    #region Setters and Getters

    public int FlgOperation
    {
        get { return flgOperation; }
        set { flgOperation = value; }
    }

    public int IdRegistrationID
    {
        get { return idRegistrationID; }
        set { idRegistrationID = value; }
    }

    public int IdProgram
    {
        get { return idProgram; }
        set { idProgram = value; }
    }

    public int IdUser
    {
        get { return idUser; }
        set { idUser = value; }
    }

    public int ID
    {
        get { return idLogTrans; }
        set { idLogTrans = value; }
    }

    public DateTime DtTransDate
    {
        get { return dtTransDate; }
        set { dtTransDate = value; }
    }

    public String STabladbUniversal
    {
        get { return sTabladbUniversal; }
        set { sTabladbUniversal = value; }
    }

    #endregion

}

#endregion


